import 'package:flutter/material.dart';

class ScaffoldDemo2 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _ScaffoldDemo2State();
  }
}

class _ScaffoldDemo2State extends State {

  var _message = '初始化文字';

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text('底部导航栏的例子'),
      ),

      body: Center(
        child: Text(_message,
        style: TextStyle(
          fontSize: 30,
          color: Colors.green,
          fontWeight: FontWeight.bold,
        ),),
      ),

      bottomNavigationBar: BottomAppBar(
        child: Row(
          children: <Widget>[
            IconButton(
              icon: Icon(Icons.home),
              onPressed: (){
                setState(() {
                  _message = '选择了首页';
                });
              },
            ),

            IconButton(
              icon: Icon(Icons.business),
              onPressed: (){
                setState(() {
                  _message = '选择了商业';
                });
              },
            ),

            SizedBox(),

            IconButton(
              icon: Icon(Icons.school),
              onPressed: (){
                setState(() {
                  _message = '选择了学校';
                });
              },
            ),

            IconButton(
              icon: Icon(Icons.hotel),
              onPressed: (){
                setState(() {
                  _message = '选择了旅馆';
                });
              },
            ),
          ],

          mainAxisAlignment: MainAxisAlignment.spaceAround,
        ),

        shape: CircularNotchedRectangle(),
      ),

      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _message = '点击了悬浮的加号按钮';
          });
        },
        child: Icon(Icons.add),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
    );
  }
}